class Solution {
public:
    void rotate(vector<int>& nums, int k)
    {
        int n = nums.size();
        for (int i = 0; i < n; i++) nums.push_back(nums[i]);
        k %= n;
        int x = n - k;
        vector<int> ans(nums.begin() + x, nums.begin() + x + n);
        nums = ans;
    }
};